
Ext.application({
    name: 'MajorProjectSenchaTouch',
    viewport:{
        autoMaximize:true
    },
    requires: [
    'Ext.MessageBox'
    ],
    controllers: ['Main', 'OpeningHours','Search', 'ContactUs', 'EResources', 'BookMarked', 'LibraryUpdates', 'DetailsView', 'Override', 'ShelfLocator','AdditionalResources','Citation','FloorPlans','LibraryVideos', 'NewArrivals'],

    models: ['EResource', 'EResourcesUrl','EResourcesCategory','Result','OpeningHoursInfo','OpLocation','OpeningHour', 'LibraryUpdate', 'floorplanData','ResultInfo', 'RecommendTitle', 'DetailsAvail', 'ShelfLocator','AnnouncementsData','LibraryVideosData'],

    views: ['MainNavView','Announcements.AnnouncementsListItem','LibraryVideosModule.LibraryVideosList','FloorPlans.floorplanList'],
    stores: ['BookMarked','EResources','EResourcesCategories', 'EResourcesMusic', 'EResourcesMusicCategory','Results','OpeningHoursTermInfo','LibraryVideosInfo','floorplanInfo',
    'OpeningHoursVBInfo', 'LibraryUpdates', 'Modules', 'ResultsInfo', 'BookMarkedMemory', 'DetailsAvails', 'DetailsMains', 'DetailsMainsTemp', 'ShelfLocator','AnnouncementsInfo'],

    launch: function() {
        
        /* (@author : Timothy Cheung)                                     */      
        /* Detects user agent of the device accessing the app's url,      */
        /* redirect user to TP library catalogue if a desktop or a tablet */
        /* Load the app if the device is recognised to be a phone         */
        //if the user agent is a phone
        if(Ext.os.is.Phone || Ext.os.is.Tablet || true){
            //if(Ext.os.is.iOS||Ext.os.is.Android){

            //load app
            Ext.fly('appLoadingIndicator').destroy();

			this.getController('Main').loadAnnouncements();
			
            var navView = {
                xtype: 'mainNavView'
            };

            Ext.Viewport.add([navView]);
        // Destroy the #appLoadingIndicator element
			
        }

        //else if the user agent is either a taablet or a desktop
        else if(Ext.os.is.Desktop)
        {
            //redirect user to TP library catalogue
            location.href = 'http://libcat.tp.edu.sg/';
        }
		
        
        ////////////////////////////////////////////////
        //* (@author : Timothy Cheung) */      
        //***Potential expansions***
        //====Detect Device's Browser====
        //if(Ext.browser.is.Chrome||Ext.browser.is.ChromeMobile)
        //Browser list: FireFox, IE, Safari, Opera, Dolfin, ChromeMobile, Silk, Other
        //
        //====Detect Device's OS====
        //if(Ext.os.is.iOS||Ext.os.is.Android)
        //OS list: iOS, iPad, iPhone, iPod, Android, WebOS, BlackBerry, Bada, MacOS, Windows, Linux, Other
        //
        //====Detect screen orientation====
        //if(Ext.orientation == 'landscape')
        //
        //if(Ext.orientation == 'portrait')
        //
        //Ref: http://docs.sencha.com/touch/2-0/#!/guide/environment_package
        //
        ////////////////////////////////////////////////
      
      
        /* Updates the url to match the current state of the app (home) (@author : Justina Lee) */      
//        this.getHistory().add(Ext.create('Ext.app.Action', {
//            url: 'home'
//        }));
    },

    onUpdated: function() {
        Ext.Msg.confirm(
            "Application Update",
            "This application has just successfully been updated to the latest version. Reload now?",
            function(buttonId) {
                if (buttonId === 'yes') {
                    window.location.reload();
                }
            }
            );
    },
	
    //global variables ---------------------------------------------------------------------------------------
    // serverUrl: 'http://152.226.238.56:3000/MP07/index.php/', <-- variable ip address
	serverUrl: 'http://localhost:3000/MP07/index.php/', 
    tpliBlogUrl: 'http://tpliblog.blogspot.sg/',
    tplibFacebookUrl: 'http://www.facebook.com/tplib',
    tplibHotline: '67805772',
    tplibEmail: 'AskLib@tp.edu.sg',
    tplibRecommendTitleEmail: 'libacq@tp.edu.sg',
    tplibExamPaperUrl: 'https://libcat.tp.edu.sg/F/?func=file&file_name=login-session-exam#bor',
    tplibMyAccUrl: 'https://libcat.tp.edu.sg/F/?func=file&file_name=login-session',
    imagesDirectory: 'resources/images/shelflocator/',
	currentUser: '',
	loanArray: Array(),
	reservationArray: Array(),
	currentExamUser: '',
	citation1:'http://library.tp.edu.sg/dmr/mobileapp/why%20must%20i%20cite.pdf',
	citation2:'http://library.tp.edu.sg/infoskills/apa_style.pdf',
	citation3:'http://library.tp.edu.sg/IRS/ieee_style.pdf',
	announcements: 'http://library.tp.edu.sg/dmr/mobileapp/libraryvideo.xml',
    floorplans:'',

	// '<area shape="rect" coords="256,198,469,291" target="staffread" href="resources/images/floorplans/images.jpg" />'+
					// '<area shape="rect" coords="21,250,237,370"  target="sem" href="resources/images/floorplans/images.jpg" />'+
					// '<area shape="rect" coords="547,255,757,373"  target="tra" href="resources/images/floorplans/images.jpg" />'+
					// '<area shape="rect" coords="329,428,466,496"  target="dth"  href="resources/images/floorplans/images.jpg" />',
    //DetailsView DetailsMainsTemp store item limit
    tempStoreLimit: '10',

    //bookmarked info
    bookmarkedAddInfo: 'Book-Marked! contains a list of books you had added after tapping on the add button at the result list.',
    bookmarkedRemoveInfo: 'To remove a bookmark from the list, tap on the remove button located at the bottom right of each bookmarked item.',
    locatorInfo: 'To help you locate the book/resource, tap on the locator button to launch the bookshelf locator!',

     //Search Message
    noKeywordEnterTitle: 'No words entered',
    noKeywordEnterBody: 'Please enter a keyword first',
    advanceNoKeywordTitle: 'First search box empty',
    advanceNoKeywordBody: 'Please enter a search term in the first search box',
    noMatchFoundTitle: 'No Match Found',
    noMatchFoundBody: 'Your search did not find any matching documents',
    errorEncounterTitle: 'Error Encountered',
    errorEncounterBody: 'The service might be temporarily unavailable or please check the keyword entered',
    noMoreResultTitle: 'Info',
    noMoreResultBody: 'No more results',
    redirectExamPMsg: 'You will be redirected to TP eExam Paper Website',
    redirectedExamPMsg: 'Redirected to TP eExam Paper Website',
    redirectToAccMsg: 'You will be redirected to TP My Account Website',
    redirectedToAccMsg: 'Redirected to TP My Account Website'
});